<%@ page language="java" import="java.util.*,news.dao.*,news.pojo.*,news.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<link href="css/read.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function checkComment(){
		var cauthor = document.getElementById("cauthor");
		var content = document.getElementById("ccontent");
		if(cauthor.value == ""){
			alert("用户名不能为空！！");
			return false;
		}else if(content.value == ""){
			alert("评论内容不能为空！！");
			return false;
		}
		return true;
	}
</script>
</head>


<div id="container">
  


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<div class="sidebar">
    <h1> <img src="images/title_1.gif" alt="国内新闻" /> </h1>
    <div class="side_list">

      <ul>      
       
      	 <%   NewsDao newsdao=new NewsDao();
  List<News> newslist= newsdao.findTop(1);
  for(News news:newslist){
  %>
  
  <li> <a href='news.jsp?nid=<%=news.getNid()%>'><b><%=news.getNtitle() %></b></a> </li> 
  <%} %> 	
      </ul>
    </div>
    <h1> <img src="images/title_2.gif" alt="国际新闻" /> </h1>
    <div class="side_list">
       <ul>      
       
      	 <%  
  List<News> newslist2= newsdao.findTop(2);
  for(News news:newslist2){
  %>
  
  <li> <a href='news.jsp?nid=<%=news.getNid()%>'><b> <%=news.getNtitle() %></b></a> </li> 
  <%} %> 	
      </ul>
    </div>
    <h1> <img src="images/title_3.gif" alt="娱乐新闻" /> </h1>
    <div class="side_list">
      <ul>      
       
      	 <%  
  List<News> newslist3= newsdao.findTop(5);
  for(News news:newslist3){
  %>
  <li> <a href='news.jsp?nid=<%=news.getNid()%>'><b> <%=news.getNtitle() %></b></a> </li> 
  <%} %> 	
      </ul>
    </div>
  </div>



  <div class="main">
    <div class="class_type"> <img src="images/class_type.gif" alt="新闻中心" /> </div>
    <div class="content">
      <ul class="classlist">
        <table width="80%" align="center">
          <tr width="100%">
          <%
          Integer nid=Integer.parseInt(request.getParameter("nid"));         
          NewsDao ndo=new NewsDao();
          News nn2=ndo.get(nid);
           %>
            <td colspan="2" align="center"><%=nn2.getNtitle() %></td>
          </tr>
          <tr>
            <td colspan="2"><hr />
            </td>
          </tr>
          <tr>
            <td align="center">作者：<%=nn2.getNauthor() %>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
             </a></td>
            <td align="left">发布时间：<%=nn2.getNcreateDate() %></td>
          </tr>          
          <tr>
            <td colspan="2" align="center"></td>
          </tr>
          <tr>
            <td colspan="2"> <p>
        
        <textarea name="nnncontent" id="ncontent" cols="90" rows="10" readonly="readonly"><%= nn2.getNcontent()%></textarea>
      </p> </td>
          </tr>
          <tr>
            <td colspan="2"><hr />
            </td>
          </tr>
        </table>
      </ul>
      <ul class="classlist">
        <table width="80%" align="center">
        <%
        CommentDao coda=new CommentDao();
        Comments cs=new Comments();
        List<Comments> lis=coda.findComments(nid);
         %>
        	<td colspan="6"> 
<%
if(lis.size()==0){
%>
暂无评论！

<%
}else{%>
<h3 style="color:green">神评榜:</h3>
<%
for(Comments comm:lis){%>
<div>用户：<span style="color:red"><%=comm.getCauthor()%></span>&nbsp&nbsp&nbsp&nbsp&nbsp
时间：<span style="color:orange"><%=comm.getCdate()%></span>&nbsp&nbspIP：<span style="color:purple"><%=comm.getCip()%></span></div>
<div>内容：<span style="color:blue"><%=comm.getCcontent()%></span></div>
<br><hr>
<%
}
}
 %>

 </td>
	          <tr>
	            <td colspan="6"><hr />
	            </td>
	          </tr>
                
          
        </table>
      </ul>
      <ul class="classlist">
        <form action="news_control.jsp?opr=addComment&nid=<%=request.getParameter("nid") %>" method="post" onSubmit="return checkComment()">
          <table width="80%" align="center">
            <tr>
              <td> 评 论 </td>
            </tr>
            <tr>
              <td> 用户名： </td>
              <td>            
	              <input id="cauthor" name="cauthor" value="无名小辈"/>	            
                IP：
                <%
                String ip=request.getRemoteAddr();              
                 %>
                <input name="cip" id="cip" value="<%out.print(ip); %>" readonly="readonly" style="border:0px;"/>
              </td>
            </tr>
            <tr>
              <td colspan="2"><textarea name="ccontent" id="ccontent" cols="70" rows="10"></textarea>
              </td>
            </tr>
            <td><input name="submit" value="发  表" type="submit"/>
              </td>
          </table>
        </form>
      </ul>
    </div>
  </div>
</div>
<div>
<%-- 
<%

int addresult=100;
try{
request.setCharacterEncoding("UTF-8");
addresult=Integer.parseInt(request.getParameter("addc"));
}catch(Exception e){}
if(addresult==1){%>
alert(添加成功！！！"");
<%
}else if(addresult==100){%>
<%
}else{%>

alert("失败！");
<% 
}


 %>
 --%>

</div>

<%@ include file="footer.jsp" %>
</body>
</html>

</html>